//
//  LabelAndTextView.m
//  BaChat
//
//  Created by 刘洋 on 16/6/14.
//  Copyright © 2016年 刘洋. All rights reserved.
//

#import "LabelAndTextView.h"

@implementation LabelAndTextView

-(void)dealloc{
    [_mylabel release];
    [_myTextField release];
    [super dealloc];
}




-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createLabelAndTextView];
    }
    return self;
    
}


-(void)createLabelAndTextView{
    
    self.mylabel = [[BaseLabel alloc]initWithFrame:CGRectMake(0, 0, ROOTWIDTH / 4, 30)];
    self.mylabel.backgroundColor = [UIColor clearColor];
 //   self.mylabel.textAlignment = NSTextAlignmentCenter;
    self.mylabel.alpha = 0.8;
    [self addSubview:self.mylabel];
    [_mylabel release];

    self.myTextField = [[UITextField alloc]initWithFrame:CGRectMake(self.mylabel.frame.size.width + 10, 0, ROOTWIDTH / 4 * 3, 30)];
    self.myTextField.backgroundColor = [UIColor clearColor];
    [self addSubview:self.myTextField];
    [_myTextField release];
    self.myTextField.delegate = self;
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,self.mylabel.frame.size.height + 2, self.frame.size.width, 1)];
    lineView.backgroundColor = [UIColor grayColor];
    lineView.alpha = 0.5;
    [self addSubview:lineView];
    [lineView release];
    
    
    
}


-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [textField resignFirstResponder];
    
    return YES;
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.myTextField resignFirstResponder];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
